<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>My Project: WebSocketClient.h 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">My Project
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.8 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function() { init_codefold(0); });
/* @license-end */
</script>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">载入中...</div>
<div class="SRStatus" id="Searching">搜索中...</div>
<div class="SRStatus" id="NoMatches">未找到</div>
</div>
</div>
</div>
</div>

<div class="header">
  <div class="headertitle"><div class="title">WebSocketClient.h</div></div>
</div><!--header-->
<div class="contents">
<a href="WebSocketClient_8h.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span> </div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno">   15</span><span class="preprocessor">#pragma once</span></div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno">   16</span> </div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno">   17</span><span class="preprocessor">#include &lt;<a class="code" href="HttpRequest_8h.html">drogon/HttpRequest.h</a>&gt;</span></div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno">   18</span><span class="preprocessor">#include &lt;<a class="code" href="HttpResponse_8h.html">drogon/HttpResponse.h</a>&gt;</span></div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno">   19</span><span class="preprocessor">#include &lt;<a class="code" href="WebSocketConnection_8h.html">drogon/WebSocketConnection.h</a>&gt;</span></div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno">   20</span><span class="preprocessor">#include &lt;<a class="code" href="HttpTypes_8h.html">drogon/HttpTypes.h</a>&gt;</span></div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno">   21</span><span class="preprocessor">#ifdef __cpp_impl_coroutine</span></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno">   22</span><span class="preprocessor">#include &lt;drogon/utils/coroutine.h&gt;</span></div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno">   23</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno">   24</span><span class="preprocessor">#include &lt;functional&gt;</span></div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno">   25</span><span class="preprocessor">#include &lt;memory&gt;</span></div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno">   26</span><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno">   27</span><span class="preprocessor">#include &lt;trantor/net/EventLoop.h&gt;</span></div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno">   28</span> </div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno">   29</span><span class="keyword">namespace </span><a class="code hl_namespace" href="namespacedrogon.html">drogon</a></div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno">   30</span>{</div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno">   31</span><span class="keyword">class </span>WebSocketClient;</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"><a class="line" href="namespacedrogon.html#ad0c26abc9bbfb0532bc364bfeecb9b74">   32</a></span><span class="keyword">using </span><a class="code hl_typedef" href="namespacedrogon.html#ad0c26abc9bbfb0532bc364bfeecb9b74">WebSocketClientPtr</a> = std::shared_ptr&lt;WebSocketClient&gt;;</div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"><a class="line" href="namespacedrogon.html#a888b4af6a797800c9eda52b877925108">   33</a></span><span class="keyword">using </span><a class="code hl_typedef" href="namespacedrogon.html#a888b4af6a797800c9eda52b877925108">WebSocketRequestCallback</a> = std::function&lt;</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno">   34</span>    void(<a class="code hl_enumeration" href="namespacedrogon.html#ad4f1bd941b74c9e31506ec1ec5f5cd91">ReqResult</a>, <span class="keyword">const</span> <a class="code hl_typedef" href="namespacedrogon.html#ab2a2d829bb017f43c2c9de72f4042baa">HttpResponsePtr</a> &amp;, <span class="keyword">const</span> <a class="code hl_typedef" href="namespacedrogon.html#ad0c26abc9bbfb0532bc364bfeecb9b74">WebSocketClientPtr</a> &amp;)&gt;;</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno">   35</span> </div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno">   36</span><span class="preprocessor">#ifdef __cpp_impl_coroutine</span></div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno">   37</span><span class="keyword">namespace </span>internal</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno">   38</span>{</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno">   39</span><span class="keyword">struct </span>[[nodiscard]] WebSocketConnectionAwaiter</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno">   40</span>    : <span class="keyword">public</span> CallbackAwaiter&lt;HttpResponsePtr&gt;</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno">   41</span>{</div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno">   42</span>    WebSocketConnectionAwaiter(<a class="code hl_class" href="classdrogon_1_1WebSocketClient.html">WebSocketClient</a> *client, <a class="code hl_typedef" href="namespacedrogon.html#a5200699555f98a809538342baa167aad">HttpRequestPtr</a> req)</div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno">   43</span>        : client_(client), req_(std::move(req))</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno">   44</span>    {</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno">   45</span>    }</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno">   46</span> </div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno">   47</span>    <span class="keywordtype">void</span> await_suspend(std::coroutine_handle&lt;&gt; handle);</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno">   48</span> </div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno">   49</span>  <span class="keyword">private</span>:</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno">   50</span>    <a class="code hl_class" href="classdrogon_1_1WebSocketClient.html">WebSocketClient</a> *client_;</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno">   51</span>    <a class="code hl_typedef" href="namespacedrogon.html#a5200699555f98a809538342baa167aad">HttpRequestPtr</a> req_;</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno">   52</span>};</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno">   53</span> </div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno">   54</span>}  <span class="comment">// namespace internal</span></div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno">   55</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno">   56</span> </div>
<div class="foldopen" id="foldopen00061" data-start="{" data-end="};">
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"><a class="line" href="classdrogon_1_1WebSocketClient.html">   61</a></span><span class="keyword">class </span><a class="code hl_define" href="exports_8h.html#a00d0a001c2dd03906272e00b0598182e">DROGON_EXPORT</a> <a class="code hl_class" href="classdrogon_1_1WebSocketClient.html">WebSocketClient</a></div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno">   62</span>{</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno">   63</span>  <span class="keyword">public</span>:</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"><a class="line" href="classdrogon_1_1WebSocketClient.html#a565eefde4f502bb10cc321d009bfed70">   65</a></span>    <span class="keyword">virtual</span> <a class="code hl_typedef" href="namespacedrogon.html#a963450dc03553ccb1c4bbc8479404eb9">WebSocketConnectionPtr</a> <a class="code hl_function" href="classdrogon_1_1WebSocketClient.html#a565eefde4f502bb10cc321d009bfed70">getConnection</a>() = 0;</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno">   66</span> </div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"><a class="line" href="classdrogon_1_1WebSocketClient.html#a69b64de687b402c2be336d0ec9c2baea">   73</a></span>    <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classdrogon_1_1WebSocketClient.html#a69b64de687b402c2be336d0ec9c2baea">setMessageHandler</a>(</div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno">   74</span>        <span class="keyword">const</span> std::function&lt;<span class="keywordtype">void</span>(std::string &amp;&amp;message,</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno">   75</span>                                 <span class="keyword">const</span> <a class="code hl_typedef" href="namespacedrogon.html#ad0c26abc9bbfb0532bc364bfeecb9b74">WebSocketClientPtr</a> &amp;,</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno">   76</span>                                 <span class="keyword">const</span> <a class="code hl_enumeration" href="namespacedrogon.html#a60c960a4500d47d200b72356dfcd06e8">WebSocketMessageType</a> &amp;)&gt; &amp;callback) = 0;</div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno">   77</span> </div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno">   80</span> </div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"><a class="line" href="classdrogon_1_1WebSocketClient.html#a9964be7a12553377c6fc2d9e514d7b3b">   86</a></span>    <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classdrogon_1_1WebSocketClient.html#a9964be7a12553377c6fc2d9e514d7b3b">setConnectionClosedHandler</a>(</div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno">   87</span>        <span class="keyword">const</span> std::function&lt;<span class="keywordtype">void</span>(<span class="keyword">const</span> <a class="code hl_typedef" href="namespacedrogon.html#ad0c26abc9bbfb0532bc364bfeecb9b74">WebSocketClientPtr</a> &amp;)&gt; &amp;callback) = 0;</div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno">   88</span> </div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno"><a class="line" href="classdrogon_1_1WebSocketClient.html#aad0a944fd92463ef578c0990f3bce4a5">   90</a></span>    <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classdrogon_1_1WebSocketClient.html#aad0a944fd92463ef578c0990f3bce4a5">connectToServer</a>(<span class="keyword">const</span> <a class="code hl_typedef" href="namespacedrogon.html#a5200699555f98a809538342baa167aad">HttpRequestPtr</a> &amp;request,</div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno">   91</span>                                 <span class="keyword">const</span> <a class="code hl_typedef" href="namespacedrogon.html#a888b4af6a797800c9eda52b877925108">WebSocketRequestCallback</a> &amp;callback) = 0;</div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno">   92</span> </div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"><a class="line" href="classdrogon_1_1WebSocketClient.html#af383e9333bd8f3611b671eaff48cd503">  101</a></span>    <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classdrogon_1_1WebSocketClient.html#af383e9333bd8f3611b671eaff48cd503">setCertPath</a>(<span class="keyword">const</span> std::string &amp;cert,</div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno">  102</span>                             <span class="keyword">const</span> std::string &amp;key) = 0;</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno">  103</span> </div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"><a class="line" href="classdrogon_1_1WebSocketClient.html#a7bc93157c9ba2bf699f37f71b44d1805">  114</a></span>    <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classdrogon_1_1WebSocketClient.html#a7bc93157c9ba2bf699f37f71b44d1805">addSSLConfigs</a>(</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno">  115</span>        <span class="keyword">const</span> std::vector&lt;std::pair&lt;std::string, std::string&gt;&gt;</div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno">  116</span>            &amp;sslConfCmds) = 0;</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno">  117</span> </div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno">  118</span><span class="preprocessor">#ifdef __cpp_impl_coroutine</span></div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno">  125</span>    <span class="keywordtype">void</span> setAsyncMessageHandler(</div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno">  126</span>        <span class="keyword">const</span> std::function&lt;Task&lt;&gt;(std::string &amp;&amp;message,</div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno">  127</span>                                   <span class="keyword">const</span> <a class="code hl_typedef" href="namespacedrogon.html#ad0c26abc9bbfb0532bc364bfeecb9b74">WebSocketClientPtr</a> &amp;,</div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno">  128</span>                                   <span class="keyword">const</span> <a class="code hl_enumeration" href="namespacedrogon.html#a60c960a4500d47d200b72356dfcd06e8">WebSocketMessageType</a> &amp;)&gt; &amp;callback)</div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno">  129</span>    {</div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno">  130</span>        setMessageHandler([callback](std::string &amp;&amp;message,</div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno">  131</span>                                     <span class="keyword">const</span> <a class="code hl_typedef" href="namespacedrogon.html#ad0c26abc9bbfb0532bc364bfeecb9b74">WebSocketClientPtr</a> &amp;client,</div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno">  132</span>                                     <span class="keyword">const</span> <a class="code hl_enumeration" href="namespacedrogon.html#a60c960a4500d47d200b72356dfcd06e8">WebSocketMessageType</a> &amp;type) -&gt; <span class="keywordtype">void</span> {</div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno">  133</span>            [callback](std::string &amp;&amp;message,</div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno">  134</span>                       <span class="keyword">const</span> <a class="code hl_typedef" href="namespacedrogon.html#ad0c26abc9bbfb0532bc364bfeecb9b74">WebSocketClientPtr</a> client,</div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno">  135</span>                       <span class="keyword">const</span> <a class="code hl_enumeration" href="namespacedrogon.html#a60c960a4500d47d200b72356dfcd06e8">WebSocketMessageType</a> type) -&gt; AsyncTask {</div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno">  136</span>                <span class="keyword">co_await</span> callback(std::move(message), client, type);</div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno">  137</span>            }(std::move(message), client, type);</div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno">  138</span>        });</div>
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno">  139</span>    }</div>
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno">  140</span> </div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno">  143</span> </div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno">  150</span>    <span class="keywordtype">void</span> setAsyncConnectionClosedHandler(</div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno">  151</span>        <span class="keyword">const</span> std::function&lt;Task&lt;&gt;(<span class="keyword">const</span> <a class="code hl_typedef" href="namespacedrogon.html#ad0c26abc9bbfb0532bc364bfeecb9b74">WebSocketClientPtr</a> &amp;)&gt; &amp;callback)</div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno">  152</span>    {</div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno">  153</span>        setConnectionClosedHandler(</div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno">  154</span>            [callback](<span class="keyword">const</span> <a class="code hl_typedef" href="namespacedrogon.html#ad0c26abc9bbfb0532bc364bfeecb9b74">WebSocketClientPtr</a> &amp;client) {</div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno">  155</span>                [=]() -&gt; AsyncTask { <span class="keyword">co_await</span> callback(client); }();</div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno">  156</span>            });</div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno">  157</span>    }</div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno">  158</span> </div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno">  160</span>    internal::WebSocketConnectionAwaiter connectToServerCoro(</div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno">  161</span>        <span class="keyword">const</span> HttpRequestPtr &amp;request)</div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno">  162</span>    {</div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno">  163</span>        <span class="keywordflow">return</span> internal::WebSocketConnectionAwaiter(<span class="keyword">this</span>, request);</div>
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno">  164</span>    }</div>
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno">  165</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno">  166</span> </div>
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno"><a class="line" href="classdrogon_1_1WebSocketClient.html#a7f38b65903f3001a4baa4cdf486e41cc">  168</a></span>    <span class="keyword">virtual</span> trantor::EventLoop *<a class="code hl_function" href="classdrogon_1_1WebSocketClient.html#a7f38b65903f3001a4baa4cdf486e41cc">getLoop</a>() = 0;</div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno">  169</span> </div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno"><a class="line" href="classdrogon_1_1WebSocketClient.html#a70db4772f4e8fb5d888eaa3b806cae47">  171</a></span>    <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classdrogon_1_1WebSocketClient.html#a70db4772f4e8fb5d888eaa3b806cae47">stop</a>() = 0;</div>
<div class="line"><a id="l00172" name="l00172"></a><span class="lineno">  172</span> </div>
<div class="line"><a id="l00192" name="l00192"></a><span class="lineno"><a class="line" href="classdrogon_1_1WebSocketClient.html#a27786bef2a65c9f4fd3dc7692fde8b1b">  192</a></span>    <span class="keyword">static</span> <a class="code hl_typedef" href="namespacedrogon.html#ad0c26abc9bbfb0532bc364bfeecb9b74">WebSocketClientPtr</a> <a class="code hl_function" href="classdrogon_1_1WebSocketClient.html#a27786bef2a65c9f4fd3dc7692fde8b1b">newWebSocketClient</a>(</div>
<div class="line"><a id="l00193" name="l00193"></a><span class="lineno">  193</span>        <span class="keyword">const</span> std::string &amp;ip,</div>
<div class="line"><a id="l00194" name="l00194"></a><span class="lineno">  194</span>        uint16_t port,</div>
<div class="line"><a id="l00195" name="l00195"></a><span class="lineno">  195</span>        <span class="keywordtype">bool</span> useSSL = <span class="keyword">false</span>,</div>
<div class="line"><a id="l00196" name="l00196"></a><span class="lineno">  196</span>        trantor::EventLoop *loop = <span class="keyword">nullptr</span>,</div>
<div class="line"><a id="l00197" name="l00197"></a><span class="lineno">  197</span>        <span class="keywordtype">bool</span> useOldTLS = <span class="keyword">false</span>,</div>
<div class="line"><a id="l00198" name="l00198"></a><span class="lineno">  198</span>        <span class="keywordtype">bool</span> validateCert = <span class="keyword">true</span>);</div>
<div class="line"><a id="l00199" name="l00199"></a><span class="lineno">  199</span> </div>
<div class="line"><a id="l00202" name="l00202"></a><span class="lineno">  202</span> </div>
<div class="line"><a id="l00224" name="l00224"></a><span class="lineno"><a class="line" href="classdrogon_1_1WebSocketClient.html#a019d63ecbee5c1022ddf50c445b5cc82">  224</a></span>    <span class="keyword">static</span> <a class="code hl_typedef" href="namespacedrogon.html#ad0c26abc9bbfb0532bc364bfeecb9b74">WebSocketClientPtr</a> <a class="code hl_function" href="classdrogon_1_1WebSocketClient.html#a019d63ecbee5c1022ddf50c445b5cc82">newWebSocketClient</a>(</div>
<div class="line"><a id="l00225" name="l00225"></a><span class="lineno">  225</span>        <span class="keyword">const</span> std::string &amp;hostString,</div>
<div class="line"><a id="l00226" name="l00226"></a><span class="lineno">  226</span>        trantor::EventLoop *loop = <span class="keyword">nullptr</span>,</div>
<div class="line"><a id="l00227" name="l00227"></a><span class="lineno">  227</span>        <span class="keywordtype">bool</span> useOldTLS = <span class="keyword">false</span>,</div>
<div class="line"><a id="l00228" name="l00228"></a><span class="lineno">  228</span>        <span class="keywordtype">bool</span> validateCert = <span class="keyword">true</span>);</div>
<div class="line"><a id="l00229" name="l00229"></a><span class="lineno">  229</span> </div>
<div class="line"><a id="l00230" name="l00230"></a><span class="lineno"><a class="line" href="classdrogon_1_1WebSocketClient.html#a23207481037a6952912466c8062d5469">  230</a></span>    <span class="keyword">virtual</span> <a class="code hl_function" href="classdrogon_1_1WebSocketClient.html#a23207481037a6952912466c8062d5469">~WebSocketClient</a>() = <span class="keywordflow">default</span>;</div>
<div class="line"><a id="l00231" name="l00231"></a><span class="lineno">  231</span>};</div>
</div>
<div class="line"><a id="l00232" name="l00232"></a><span class="lineno">  232</span> </div>
<div class="line"><a id="l00233" name="l00233"></a><span class="lineno">  233</span><span class="preprocessor">#ifdef __cpp_impl_coroutine</span></div>
<div class="line"><a id="l00234" name="l00234"></a><span class="lineno">  234</span><span class="keyword">inline</span> <span class="keywordtype">void</span> internal::WebSocketConnectionAwaiter::await_suspend(</div>
<div class="line"><a id="l00235" name="l00235"></a><span class="lineno">  235</span>    std::coroutine_handle&lt;&gt; handle)</div>
<div class="line"><a id="l00236" name="l00236"></a><span class="lineno">  236</span>{</div>
<div class="line"><a id="l00237" name="l00237"></a><span class="lineno">  237</span>    client_-&gt;connectToServer(req_,</div>
<div class="line"><a id="l00238" name="l00238"></a><span class="lineno">  238</span>                             [<span class="keyword">this</span>, handle](<a class="code hl_enumeration" href="namespacedrogon.html#ad4f1bd941b74c9e31506ec1ec5f5cd91">ReqResult</a> result,</div>
<div class="line"><a id="l00239" name="l00239"></a><span class="lineno">  239</span>                                            <span class="keyword">const</span> <a class="code hl_typedef" href="namespacedrogon.html#ab2a2d829bb017f43c2c9de72f4042baa">HttpResponsePtr</a> &amp;resp,</div>
<div class="line"><a id="l00240" name="l00240"></a><span class="lineno">  240</span>                                            <span class="keyword">const</span> <a class="code hl_typedef" href="namespacedrogon.html#ad0c26abc9bbfb0532bc364bfeecb9b74">WebSocketClientPtr</a> &amp;) {</div>
<div class="line"><a id="l00241" name="l00241"></a><span class="lineno">  241</span>                                 <span class="keywordflow">if</span> (result == <a class="code hl_enumvalue" href="namespacedrogon.html#ad4f1bd941b74c9e31506ec1ec5f5cd91aa60852f204ed8028c1c58808b746d115">ReqResult::Ok</a>)</div>
<div class="line"><a id="l00242" name="l00242"></a><span class="lineno">  242</span>                                     setValue(resp);</div>
<div class="line"><a id="l00243" name="l00243"></a><span class="lineno">  243</span>                                 <span class="keywordflow">else</span></div>
<div class="line"><a id="l00244" name="l00244"></a><span class="lineno">  244</span>                                 {</div>
<div class="line"><a id="l00245" name="l00245"></a><span class="lineno">  245</span>                                     std::string reason;</div>
<div class="line"><a id="l00246" name="l00246"></a><span class="lineno">  246</span>                                     <span class="keywordflow">if</span> (result == <a class="code hl_enumvalue" href="namespacedrogon.html#ad4f1bd941b74c9e31506ec1ec5f5cd91a69225342032d63eb5ae5bdba03c8f37f">ReqResult::BadResponse</a>)</div>
<div class="line"><a id="l00247" name="l00247"></a><span class="lineno">  247</span>                                         reason = <span class="stringliteral">&quot;BadResponse&quot;</span>;</div>
<div class="line"><a id="l00248" name="l00248"></a><span class="lineno">  248</span>                                     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (result ==</div>
<div class="line"><a id="l00249" name="l00249"></a><span class="lineno">  249</span>                                              <a class="code hl_enumvalue" href="namespacedrogon.html#ad4f1bd941b74c9e31506ec1ec5f5cd91a6cb988c5999e71a093463cd3a34b93fe">ReqResult::NetworkFailure</a>)</div>
<div class="line"><a id="l00250" name="l00250"></a><span class="lineno">  250</span>                                         reason = <span class="stringliteral">&quot;NetworkFailure&quot;</span>;</div>
<div class="line"><a id="l00251" name="l00251"></a><span class="lineno">  251</span>                                     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (result ==</div>
<div class="line"><a id="l00252" name="l00252"></a><span class="lineno">  252</span>                                              <a class="code hl_enumvalue" href="namespacedrogon.html#ad4f1bd941b74c9e31506ec1ec5f5cd91a25b4606261e61bd44a81ce057e99551e">ReqResult::BadServerAddress</a>)</div>
<div class="line"><a id="l00253" name="l00253"></a><span class="lineno">  253</span>                                         reason = <span class="stringliteral">&quot;BadServerAddress&quot;</span>;</div>
<div class="line"><a id="l00254" name="l00254"></a><span class="lineno">  254</span>                                     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (result == <a class="code hl_enumvalue" href="namespacedrogon.html#ad4f1bd941b74c9e31506ec1ec5f5cd91ac85a251cc457840f1e032f1b733e9398">ReqResult::Timeout</a>)</div>
<div class="line"><a id="l00255" name="l00255"></a><span class="lineno">  255</span>                                         reason = <span class="stringliteral">&quot;Timeout&quot;</span>;</div>
<div class="line"><a id="l00256" name="l00256"></a><span class="lineno">  256</span>                                     setException(std::make_exception_ptr(</div>
<div class="line"><a id="l00257" name="l00257"></a><span class="lineno">  257</span>                                         std::runtime_error(reason)));</div>
<div class="line"><a id="l00258" name="l00258"></a><span class="lineno">  258</span>                                 }</div>
<div class="line"><a id="l00259" name="l00259"></a><span class="lineno">  259</span>                                 handle.resume();</div>
<div class="line"><a id="l00260" name="l00260"></a><span class="lineno">  260</span>                             });</div>
<div class="line"><a id="l00261" name="l00261"></a><span class="lineno">  261</span>}</div>
<div class="line"><a id="l00262" name="l00262"></a><span class="lineno">  262</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00263" name="l00263"></a><span class="lineno">  263</span> </div>
<div class="line"><a id="l00264" name="l00264"></a><span class="lineno">  264</span>}  <span class="comment">// namespace drogon</span></div>
<div class="ttc" id="aHttpRequest_8h_html"><div class="ttname"><a href="HttpRequest_8h.html">HttpRequest.h</a></div></div>
<div class="ttc" id="aHttpResponse_8h_html"><div class="ttname"><a href="HttpResponse_8h.html">HttpResponse.h</a></div></div>
<div class="ttc" id="aHttpTypes_8h_html"><div class="ttname"><a href="HttpTypes_8h.html">HttpTypes.h</a></div></div>
<div class="ttc" id="aWebSocketConnection_8h_html"><div class="ttname"><a href="WebSocketConnection_8h.html">WebSocketConnection.h</a></div></div>
<div class="ttc" id="aclassdrogon_1_1WebSocketClient_html"><div class="ttname"><a href="classdrogon_1_1WebSocketClient.html">drogon::WebSocketClient</a></div><div class="ttdoc">WebSocket client abstract class</div><div class="ttdef"><b>Definition</b> WebSocketClient.h:62</div></div>
<div class="ttc" id="aclassdrogon_1_1WebSocketClient_html_a019d63ecbee5c1022ddf50c445b5cc82"><div class="ttname"><a href="classdrogon_1_1WebSocketClient.html#a019d63ecbee5c1022ddf50c445b5cc82">drogon::WebSocketClient::newWebSocketClient</a></div><div class="ttdeci">static WebSocketClientPtr newWebSocketClient(const std::string &amp;hostString, trantor::EventLoop *loop=nullptr, bool useOldTLS=false, bool validateCert=true)</div></div>
<div class="ttc" id="aclassdrogon_1_1WebSocketClient_html_a23207481037a6952912466c8062d5469"><div class="ttname"><a href="classdrogon_1_1WebSocketClient.html#a23207481037a6952912466c8062d5469">drogon::WebSocketClient::~WebSocketClient</a></div><div class="ttdeci">virtual ~WebSocketClient()=default</div></div>
<div class="ttc" id="aclassdrogon_1_1WebSocketClient_html_a27786bef2a65c9f4fd3dc7692fde8b1b"><div class="ttname"><a href="classdrogon_1_1WebSocketClient.html#a27786bef2a65c9f4fd3dc7692fde8b1b">drogon::WebSocketClient::newWebSocketClient</a></div><div class="ttdeci">static WebSocketClientPtr newWebSocketClient(const std::string &amp;ip, uint16_t port, bool useSSL=false, trantor::EventLoop *loop=nullptr, bool useOldTLS=false, bool validateCert=true)</div><div class="ttdoc">Create a websocket client using the given ip and port to connect to server.</div></div>
<div class="ttc" id="aclassdrogon_1_1WebSocketClient_html_a565eefde4f502bb10cc321d009bfed70"><div class="ttname"><a href="classdrogon_1_1WebSocketClient.html#a565eefde4f502bb10cc321d009bfed70">drogon::WebSocketClient::getConnection</a></div><div class="ttdeci">virtual WebSocketConnectionPtr getConnection()=0</div><div class="ttdoc">Get the WebSocket connection that is typically used to send messages.</div></div>
<div class="ttc" id="aclassdrogon_1_1WebSocketClient_html_a69b64de687b402c2be336d0ec9c2baea"><div class="ttname"><a href="classdrogon_1_1WebSocketClient.html#a69b64de687b402c2be336d0ec9c2baea">drogon::WebSocketClient::setMessageHandler</a></div><div class="ttdeci">virtual void setMessageHandler(const std::function&lt; void(std::string &amp;&amp;message, const WebSocketClientPtr &amp;, const WebSocketMessageType &amp;)&gt; &amp;callback)=0</div><div class="ttdoc">Set messages handler. When a message is received from the server, the callback is called.</div></div>
<div class="ttc" id="aclassdrogon_1_1WebSocketClient_html_a70db4772f4e8fb5d888eaa3b806cae47"><div class="ttname"><a href="classdrogon_1_1WebSocketClient.html#a70db4772f4e8fb5d888eaa3b806cae47">drogon::WebSocketClient::stop</a></div><div class="ttdeci">virtual void stop()=0</div><div class="ttdoc">Stop trying to connect to the server or close the connection.</div></div>
<div class="ttc" id="aclassdrogon_1_1WebSocketClient_html_a7bc93157c9ba2bf699f37f71b44d1805"><div class="ttname"><a href="classdrogon_1_1WebSocketClient.html#a7bc93157c9ba2bf699f37f71b44d1805">drogon::WebSocketClient::addSSLConfigs</a></div><div class="ttdeci">virtual void addSSLConfigs(const std::vector&lt; std::pair&lt; std::string, std::string &gt; &gt; &amp;sslConfCmds)=0</div><div class="ttdoc">Supplies command style options for SSL_CONF_cmd</div></div>
<div class="ttc" id="aclassdrogon_1_1WebSocketClient_html_a7f38b65903f3001a4baa4cdf486e41cc"><div class="ttname"><a href="classdrogon_1_1WebSocketClient.html#a7f38b65903f3001a4baa4cdf486e41cc">drogon::WebSocketClient::getLoop</a></div><div class="ttdeci">virtual trantor::EventLoop * getLoop()=0</div><div class="ttdoc">Get the event loop of the client;</div></div>
<div class="ttc" id="aclassdrogon_1_1WebSocketClient_html_a9964be7a12553377c6fc2d9e514d7b3b"><div class="ttname"><a href="classdrogon_1_1WebSocketClient.html#a9964be7a12553377c6fc2d9e514d7b3b">drogon::WebSocketClient::setConnectionClosedHandler</a></div><div class="ttdeci">virtual void setConnectionClosedHandler(const std::function&lt; void(const WebSocketClientPtr &amp;)&gt; &amp;callback)=0</div><div class="ttdoc">Set the connection closing handler. When the websocket connection is closed, the callback is called</div></div>
<div class="ttc" id="aclassdrogon_1_1WebSocketClient_html_aad0a944fd92463ef578c0990f3bce4a5"><div class="ttname"><a href="classdrogon_1_1WebSocketClient.html#aad0a944fd92463ef578c0990f3bce4a5">drogon::WebSocketClient::connectToServer</a></div><div class="ttdeci">virtual void connectToServer(const HttpRequestPtr &amp;request, const WebSocketRequestCallback &amp;callback)=0</div><div class="ttdoc">Connect to the server.</div></div>
<div class="ttc" id="aclassdrogon_1_1WebSocketClient_html_af383e9333bd8f3611b671eaff48cd503"><div class="ttname"><a href="classdrogon_1_1WebSocketClient.html#af383e9333bd8f3611b671eaff48cd503">drogon::WebSocketClient::setCertPath</a></div><div class="ttdeci">virtual void setCertPath(const std::string &amp;cert, const std::string &amp;key)=0</div><div class="ttdoc">Set the client certificate used by the HTTP connection</div></div>
<div class="ttc" id="aexports_8h_html_a00d0a001c2dd03906272e00b0598182e"><div class="ttname"><a href="exports_8h.html#a00d0a001c2dd03906272e00b0598182e">DROGON_EXPORT</a></div><div class="ttdeci">#define DROGON_EXPORT</div><div class="ttdef"><b>Definition</b> exports.h:15</div></div>
<div class="ttc" id="anamespacedrogon_html"><div class="ttname"><a href="namespacedrogon.html">drogon</a></div><div class="ttdoc">Drogon Test is a minimal effort test framework developed because the major C++ test frameworks doesn'...</div><div class="ttdef"><b>Definition</b> Attribute.h:23</div></div>
<div class="ttc" id="anamespacedrogon_html_a5200699555f98a809538342baa167aad"><div class="ttname"><a href="namespacedrogon.html#a5200699555f98a809538342baa167aad">drogon::HttpRequestPtr</a></div><div class="ttdeci">std::shared_ptr&lt; HttpRequest &gt; HttpRequestPtr</div><div class="ttdef"><b>Definition</b> drogon_callbacks.h:26</div></div>
<div class="ttc" id="anamespacedrogon_html_a60c960a4500d47d200b72356dfcd06e8"><div class="ttname"><a href="namespacedrogon.html#a60c960a4500d47d200b72356dfcd06e8">drogon::WebSocketMessageType</a></div><div class="ttdeci">WebSocketMessageType</div><div class="ttdef"><b>Definition</b> HttpTypes.h:214</div></div>
<div class="ttc" id="anamespacedrogon_html_a888b4af6a797800c9eda52b877925108"><div class="ttname"><a href="namespacedrogon.html#a888b4af6a797800c9eda52b877925108">drogon::WebSocketRequestCallback</a></div><div class="ttdeci">std::function&lt; void(ReqResult, const HttpResponsePtr &amp;, const WebSocketClientPtr &amp;)&gt; WebSocketRequestCallback</div><div class="ttdef"><b>Definition</b> WebSocketClient.h:34</div></div>
<div class="ttc" id="anamespacedrogon_html_a963450dc03553ccb1c4bbc8479404eb9"><div class="ttname"><a href="namespacedrogon.html#a963450dc03553ccb1c4bbc8479404eb9">drogon::WebSocketConnectionPtr</a></div><div class="ttdeci">std::shared_ptr&lt; WebSocketConnection &gt; WebSocketConnectionPtr</div><div class="ttdef"><b>Definition</b> WebSocketConnection.h:235</div></div>
<div class="ttc" id="anamespacedrogon_html_ab2a2d829bb017f43c2c9de72f4042baa"><div class="ttname"><a href="namespacedrogon.html#ab2a2d829bb017f43c2c9de72f4042baa">drogon::HttpResponsePtr</a></div><div class="ttdeci">std::shared_ptr&lt; HttpResponse &gt; HttpResponsePtr</div><div class="ttdef"><b>Definition</b> drogon_callbacks.h:24</div></div>
<div class="ttc" id="anamespacedrogon_html_ad0c26abc9bbfb0532bc364bfeecb9b74"><div class="ttname"><a href="namespacedrogon.html#ad0c26abc9bbfb0532bc364bfeecb9b74">drogon::WebSocketClientPtr</a></div><div class="ttdeci">std::shared_ptr&lt; WebSocketClient &gt; WebSocketClientPtr</div><div class="ttdef"><b>Definition</b> WebSocketClient.h:32</div></div>
<div class="ttc" id="anamespacedrogon_html_ad4f1bd941b74c9e31506ec1ec5f5cd91"><div class="ttname"><a href="namespacedrogon.html#ad4f1bd941b74c9e31506ec1ec5f5cd91">drogon::ReqResult</a></div><div class="ttdeci">ReqResult</div><div class="ttdef"><b>Definition</b> HttpTypes.h:202</div></div>
<div class="ttc" id="anamespacedrogon_html_ad4f1bd941b74c9e31506ec1ec5f5cd91a25b4606261e61bd44a81ce057e99551e"><div class="ttname"><a href="namespacedrogon.html#ad4f1bd941b74c9e31506ec1ec5f5cd91a25b4606261e61bd44a81ce057e99551e">drogon::ReqResult::BadServerAddress</a></div><div class="ttdeci">@ BadServerAddress</div></div>
<div class="ttc" id="anamespacedrogon_html_ad4f1bd941b74c9e31506ec1ec5f5cd91a69225342032d63eb5ae5bdba03c8f37f"><div class="ttname"><a href="namespacedrogon.html#ad4f1bd941b74c9e31506ec1ec5f5cd91a69225342032d63eb5ae5bdba03c8f37f">drogon::ReqResult::BadResponse</a></div><div class="ttdeci">@ BadResponse</div></div>
<div class="ttc" id="anamespacedrogon_html_ad4f1bd941b74c9e31506ec1ec5f5cd91a6cb988c5999e71a093463cd3a34b93fe"><div class="ttname"><a href="namespacedrogon.html#ad4f1bd941b74c9e31506ec1ec5f5cd91a6cb988c5999e71a093463cd3a34b93fe">drogon::ReqResult::NetworkFailure</a></div><div class="ttdeci">@ NetworkFailure</div></div>
<div class="ttc" id="anamespacedrogon_html_ad4f1bd941b74c9e31506ec1ec5f5cd91aa60852f204ed8028c1c58808b746d115"><div class="ttname"><a href="namespacedrogon.html#ad4f1bd941b74c9e31506ec1ec5f5cd91aa60852f204ed8028c1c58808b746d115">drogon::ReqResult::Ok</a></div><div class="ttdeci">@ Ok</div></div>
<div class="ttc" id="anamespacedrogon_html_ad4f1bd941b74c9e31506ec1ec5f5cd91ac85a251cc457840f1e032f1b733e9398"><div class="ttname"><a href="namespacedrogon.html#ad4f1bd941b74c9e31506ec1ec5f5cd91ac85a251cc457840f1e032f1b733e9398">drogon::ReqResult::Timeout</a></div><div class="ttdeci">@ Timeout</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8
</small></address>
</body>
</html>
